;(function($,window){
    var chartfunction=new chartFun();
    chartfunction.loadingPage(function () {



        //数字增长
        $('#num_1').countTo({
            formatter: function(b,a){return b.toFixed(0);}
        });
        $('#num_2').countTo({
            formatter:function(b,a){return b.toFixed(0);}
        });
        $('#num_3').countTo({
            formatter:function(b,a){return b.toFixed(0);}
        });
        $('#num_4').countTo({
            formatter:function(b,a){return b.toFixed(0);}
        });
        $('#num_5').countTo({
            formatter:function(b,a){return b.toFixed(0);}
        });

        //动态增长
        var numTotal=$("#numTotal").rollNumDaq({
            deVal:7797835
        });

        function refreshFuncitonCh(){
            refreshFuncitonFa();
        }
        //数字刷新
        function refreshFuncitonFa(){
            $.ajax({
                url:'./javascript/map/350100.json',
                success:function(data){
                    /***************异步请求***************/
                    refreshCount($('#num_1'),412);
                    refreshCount($('#num_2'),365);
                    refreshCount($('#num_3'),0);
                    refreshCount($('#num_4'),23);

                    numTotal.scroToNum(2021261);/*动态增长*/

                    //非动态增长
                    var pieDatan={
                        series:[{
                            name:'历史办结数',
                            data:[
                                {value:3251222, name:'已办结'},
                                {value:400, name:'未办结'}
                            ]
                        }]
                    };
                    chartfunction.refreshLiquidFill(pie3,pieDatan);
                    /***************异步请求***************/

                    setTimeout(refreshFuncitonCh,114000);

                }
            });
        }


        //办结率满意率
        var pieData1={
            series:[{
                name:'及时办结率',
                data:[
                    {value:1353256, name:'已办结'},
                    {value:13256, name:'未办结'}
                ]
            }]
        };
        pieData1.color=['#31a7fc'];
        var pieData2={
            series:[{
                name:'用户满意率',
                data:[
                    {value:1482154, name:'满意'},
                    {value:70000, name:'不满意'}
                ]
            }]
        };
        pieData2.color=['#da6c3b'];
        var pie2=chartfunction.echartTowPieInit('pie2',pieData1);
        var pie3=chartfunction.echartTowPieInit('pie3',pieData2);

        //柱状
        var barData={
            yAxis:[{
                data: ['福州','莆田','厦门','平潭','泉州','三明','南平','宁德','漳州','龙岩']
            }],
            series: [
                {
                    name:'用户满意率',
                    data:[
                        {name:'福州',value:90,flag:'0'},
                        {name:'莆田',value:99,flag:'1'},
                        {name:'厦门',value:88,flag:'0'},
                        {name:'平潭',value:78,flag:'1'},
                        {name:'泉州',value:68,flag:'1'},
                        {name:'三明',value:58,flag:'2'},
                        {name:'南平',value:48,flag:'0'},
                        {name:'宁德',value:42,flag:'1'},
                        {name:'漳州',value:41,flag:'0'},
                        {name:'龙岩',value:35,flag:'1'}
                    ]
                },
                {
                    name:'及时办结率',
                    data:[
                        {name:'福州',value:98,flag:'0'},
                        {name:'莆田',value:92,flag:'1'},
                        {name:'厦门',value:99,flag:'1'},
                        {name:'平潭',value:77,flag:'1'},
                        {name:'泉州',value:66,flag:'0'},
                        {name:'三明',value:55,flag:'2'},
                        {name:'南平',value:32,flag:'0'},
                        {name:'宁德',value:33,flag:'1'},
                        {name:'漳州',value:21,flag:'0'},
                        {name:'龙岩',value:20,flag:'0'}
                    ]
                }
            ]};
        var bar1=chartfunction.echartBarIndexInit('bar1',barData,5000);//默认5000ms,代表排序切换间隔时间
        //chartfunction.IntervalIns(bar1,3500);

        //排序表格
        var sortData={
            series: [
                {
                    name:'办理总数',
                    data:[
                        {name:'福州',value:37458,flagNum:'0', num:1},
                        {name:'厦门',value:23655,flagNum:'1', num:1},
                        {name:'泉州',value:6855,flagNum:'0', num:3},
                        {name:'宁德',value:5555,flagNum:'1', num:2},
                        {name:'莆田',value:5212,flagNum:'2', num:0},
                        {name:'漳州',value:3455,flagNum:'0', num:1},
                        {name:'三明',value:2344,flagNum:'1', num:1},
                        {name:'南平',value:1234,flagNum:'0', num:3},
                        {name:'平潭',value:555,flagNum:'1', num:2}/*,
                    {name:'宁德',value:212,flagNum:'2', num:0}*/
                    ]
                }
            ]};
        var sort1=chartfunction.echartSortInit('sort1',sortData);

        //饼图1
        var pieData={
            series:[{
                data:[
                    {value:6000, name:'投诉(含举报)',child:[
                            {value:3372, name:'城乡建设'},
                            {value:1506, name:'环境保护'},
                            {value:654, name:'民政'},
                            {value:468, name:'其他'}
                        ]},
                    {value:2985, name:'咨询',child:[
                            {value:1285, name:'城乡建设'},
                            {value:654, name:'政法'},
                            {value:600, name:'教育'},
                            {value:446, name:'其他'}
                        ]},
                    {value:379, name:'其他',child:[
                            {value:397, name:'其他'}
                        ]}
                ]
            }]
        };
        var pie1=chartfunction.echartPieIndexInit('pie1',pieData);

        //树图
        var treeData={
            name:'接入情况',
            series:[{
                data:[
                    {name:'省平台',value:8100,userValue:'2.5万'},
                    {name:'省直单位',value:68,preValue:98},
                    {name:'市直单位',value:1100,preValue:96},
                    {name:'区县单位',value:7203,preValue:92}
                ]
            }]

        };
        var tree1=chartfunction.treeInfoInit('tree-chart',treeData);


        //热词度图
        var hot=new hotChart();
        var pieData3={
            series:[{
                name:'热词度',
                data:[
                    {value:6563, name:'满意'},
                    {value:5337, name:'噪音'},
                    {value:4848, name:'交通'},
                    {value:4397, name:'居住证'},
                    {value:3898, name:'污染'},
                    {value:3810, name:'停车'},
                    {value:3148, name:'路灯'},
                    {value:3073, name:'投诉'},
                    {value:2066, name:'其他'}
                ]
            }]
        };
        var hotpie=hot.init('hot',pieData3);

        //柱状图2
        var barData2={
            yAxis:[{
                data: ['福州市直属','厦门市同安区','平潭','莆田市城厢区','泉州市鲤城区']
            }],
            series:[
                {
                    data:[
                        {name:'福州市直属',value:44,flagPre:2,pre:0,flagNum:2,num:0},
                        {name:'厦门市同安区',value:22,flagPre:2,pre:0,flagNum:2,num:0},
                        {name:'平潭',value:11,flagPre:11,pre:0,flagNum:2,num:0},
                        {name:'莆田市城厢区',value:11,flagPre:2,pre:0,flagNum:2,num:0},
                        {name:'泉州市鲤城区',value:11,flagPre:2,pre:0,flagNum:2,num:0}
                    ]
                }
            ]
        };
        var bar2=chartfunction.echartBar2Init('bar2',barData2);

        //---------地图 begin----------
        var mapData={
            series:[{
                name:'地图',
                data:[
                    {name:'福州市',value:2000},
                    {name:'省平台',value:135},
                    {name:'莆田市',value:1100},
                    {name:'龙岩市',value:1235},
                    {name:'厦门市',value:1465},
                    {name:'漳州市',value:800},
                    {name:'南平市',value:430},
                    {name:'三明市',value:100},
                    {name:'宁德市',value:545},
                    {name:'泉州市',value:1328},
                    {name:'平潭',value:1228}
                ],
                lines:[
                    {name:'省平台-漳州市',fromName:'省平台',toName:'漳州市',value:20},
                    {name:'漳州市-省平台',fromName:'漳州市',toName:'省平台',value:20},
                    {name:'省平台-三明市',fromName:'省平台',toName:'三明市',value:10},
                    {name:'三明市-省平台',fromName:'三明市',toName:'省平台',value:10},
                    {name:'厦门市-省平台',fromName:'厦门市',toName:'省平台',value:12},
                    {name:'平潭-省平台',fromName:'平潭',toName:'省平台',value:12},
                    {name:'省平台-平潭',fromName:'省平台',toName:'平潭',value:12}
                ]
            }]
        };
        var map1;
        $.get('./javascript/map/fujian.json', function (geoJson) {
            echarts.registerMap('FZ', geoJson);
            map1=chartfunction.echartMapInit('map1',mapData);
            //chartfunction.IntervalIns(map1,4000);
        });
        //-----------地图 end----------

        chartfunction.upadataTime('',1000);

        // 开始定时刷新
        setTimeout(function () {
            //柱状图
            chartfunction.updataByUrl(bar1,{
                url:'./javascript/map/a.json',
                durs:5000
            });

            //表格排序图
            /*chartfunction.updataByUrl(sort1,{
                url:'./javascript/map/b.json',
                durs:1500
            });*/
            //饼图
            /*chartfunction.updataByUrl(pie1,{
                url:'./javascript/map/c.json',
                durs:1500
            });*/
            //百分环图1
            chartfunction.updataByUrl(pie2,{
                url:'./javascript/map/d.json',
                durs:1500
            });
            //百分环图2
            chartfunction.updataByUrl(pie3,{
                url:'./javascript/map/e.json',
                durs:1500
            });

            //树图信息
            /*chartfunction.updataByUrl(tree1,{
                url:'./javascript/map/f.json',
                durs:15000
            });*/

            //热词图
            hot.updataByUrl(hotpie,{
                url:'./javascript/map/h.json',
                durs:100000
            });

            //斜纹条形图
            chartfunction.updataByUrl(bar2,{
                url:'./javascript/map/g.json',
                durs:15000
            });

            //地图
            chartfunction.updataMapByUrl(map1,{
                url:'./javascript/map/map.json',
                durs:15000
            });


        },5000);

        //改变屏幕时
        $(window).resize(function(){
            pie1.resize();
            pie2.resize();
            pie3.resize();
            bar1.resize();
            bar2.resize();
            map1.resize();
            numTotal.scroToNum();
        });

    },800);


})(jQuery,window);


